from django.db import models
from apps.common.base.models import BaseModel
from apps.interface.pageConfig.models import PageConfig
from apps.interface.component.models import Component

class Node(BaseModel):

    status = (
        (0, "关闭"),
        (1, "正常"),
    )

    key=models.CharField("标识", max_length=200, blank=True, null=True, default='')
    pageConfig=models.ForeignKey(PageConfig, related_name='node_PageConfig', verbose_name='所属界面配置', on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    component=models.ForeignKey(Component, related_name='node_component', verbose_name='组件', on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    status = models.IntegerField("状态", choices=status, default=1)
    isShow=models.BooleanField("是否显示节点", blank=True, default=True)
    isTemplate=models.BooleanField("是否为模板", blank=True, default=False)
    query = models.CharField("参数", max_length=200, blank=True, null=True, default='')

    config = models.TextField("配置", max_length=10000, null=True, blank=True, default='')

    options1=models.CharField("可选项1", max_length=1000, blank=True, null=True, default='')
    options2=models.CharField("可选项2", max_length=1000, blank=True, null=True, default='')


    class Meta:
        verbose_name = 'Node'
        verbose_name_plural = verbose_name


# 通知栏 options1：静态static， 动态dynamic
# 如果是动态dynamic，取options1值：{"table":"learn", "key": "name"}